#ifndef __KEYRECOMMANDER_H__
#define __KEYRECOMMANDER_H__
#include"Candidate.h"
#include"Dictionary.h"
#include<string>
#include<queue>
#include<vector>
#include<set>
#include"nlohmann/json.hpp"

using std::string;
using std::priority_queue;
using std::vector;
using std::set;

class KeyRecommander
{
public:
    KeyRecommander(string& query,Dictionary* dict);
    KeyRecommander(Dictionary* dict);
    nlohmann::json recommand(string& req);
    void execute();
    void queryIndexTable();
    nlohmann::json response();
private:
    void statistic(set<int> & iset);
    int distance(const string & rhs);

private:
    string _sought;
    Dictionary* _dict;
    priority_queue<Candidate> _result;
};

#endif
